package com.jsoft.model;

import com.jsoft.dto.SectorDto;
import com.jsoft.model.core.BaseDao;

import javax.persistence.*;
import java.util.List;

/**
 * Date: 15.08.13
 * Time: 13:56
 */

@Entity
@Table(name = "sector")
public class SectorDao extends BaseDao {
    @Column(name = "name", nullable = false)
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "department_id", nullable = false)
    private DepartmentDao department;
    @OneToMany(mappedBy = "sector")
    private List<PlaceDao> placeList;
    @OneToOne(mappedBy = "sector")
    private MenuDao menu;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public DepartmentDao getDepartment() {
        return department;
    }

    public void setDepartment(DepartmentDao department) {
        this.department = department;
    }

    public List<PlaceDao> getPlaceList() {
        return placeList;
    }

    public void setPlaceList(List<PlaceDao> placeList) {
        this.placeList = placeList;
    }

    public MenuDao getMenu() {
        return menu;
    }

    public void setMenu(MenuDao menu) {
        this.menu = menu;
    }

    public SectorDto wrapSectorDto() {
        SectorDto dto = new SectorDto();
        dto.setId(this.getObjectId());
        dto.setName(this.getName());
        return dto;
    }

    public SectorDao wrapSectorDao(SectorDto dto) {
        SectorDao dao = new SectorDao();
        dao.setName(dto.getName());
        return dao;
    }
}
